// 流程控件管理接口
import { ajaxService } from '@/utils/request';
import { FlowForm, FlowFormSubsetDetail, FlowFormControlDetail } from './type';

const env = import.meta.env;
const baseURL = env.VITE_BASE_URL;
/**
 *
 * @param data 添加流程控件
 * @returns
 */
export async function AddFlowCtl(data: FlowForm) {
  return ajaxService({
    url: '/flow/form/element',
    method: 'post',
    baseURL,
    data
  });
}
/**
 * 获取流程控件列表
 * @param params
 * @returns
 */
export async function getFlowCtlList(processId: number) {
  return ajaxService<{
    formInfo: FlowForm;
  }>({
    url: `/flow/form/info/${processId}`,
    method: 'get',
    baseURL
  });
}

export async function getFlowCtlById(id: number) {
  return ajaxService<{ content: any }>({
    url: `/flow/control/ctl/${id}`,
    method: 'get',
    baseURL
  });
}
/**
 * 编辑流程控件
 * @param params
 * @returns
 */
export async function editFlowCtl(data: FlowForm) {
  return ajaxService({
    url: '/flow/control/ctl',
    method: 'put',
    baseURL,
    data
  });
}
/**
 * 删除流程控件
 * @param params
 * @returns
 */
export async function delFlowCtlByIds(data: { ids: number[] }) {
  return ajaxService({
    url: `/flow/control/ctl`,
    method: 'delete',
    baseURL,
    data
  });
}
